﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace Card.Manager
{
    public partial class OrderManager : BasePage
    {
        #region
        private int Records
        {
            get
            {
                int _Records = 50;
                if (int.TryParse(this.txtRecords.Text, out _Records) && _Records > 0)
                {
                    return _Records;
                }
                else
                {
                    this.txtRecords.Text = "50";
                    return 50;
                }
            }
        }
        #endregion

        #region
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.DoInit();
            }
        }
        #endregion

        #region
        private void DoInit()
        {
            Card.Utility.ControlUtility.BindListControl<BAF.Entity.LookupValue>(this.dropPayment, Common.LookUpCache.GetLookupValues(CONST.LOOKUP_TYPE.PAYMENT_METHOD), "Value", "LookupCode", true);
            Common.CardWebUtility.BindOrderStatus(this.dropStatus, true);
            this.DoQuery();            
        }

        private void DoQuery()
        {
            this.rptList.DataSource = BLL.OrderManager.Query(new Card.Entity.Order()
            {
                OrderID = this.txtOrderID.Text.Trim(),
                PaymentMethodCode = this.dropPayment.SelectedValue,
                OrderStatusCode = this.dropStatus.SelectedValue,
            }, this.txtUserName.Text.Trim(), this.Records,this.Passport);
            this.rptList.DataBind();
        }
        #endregion

        protected void btnQuery_Click(object sender, EventArgs e)
        {
            this.DoQuery(); ;
        }
    }
}
